cmake_minimum_required(VERSION 3.13.0)

project(server)

find_package(Poco COMPONENTS
    Foundation
    Util
    Net
    Data
    DataMySQL)

if (NOT Poco_FOUND)
    include_directories("/usr/include/Poco")
    link_libraries(
        /usr/lib/x86_64-linux-gnu/libPocoFoundation.so
        /usr/lib/x86_64-linux-gnu/libPocoUtil.so
        /usr/lib/x86_64-linux-gnu/libPocoNet.so
        /usr/lib/x86_64-linux-gnu/libPocoData.so
        /usr/lib/x86_64-linux-gnu/libPocoJSON.so
        /usr/lib/x86_64-linux-gnu/libPocoDataMySQL.so)
endif()

file(GLOB_RECURSE SRC_HTTPSERVER httpserver/*.cpp httpserver/*.h)
file(GLOB_RECURSE SRC_MYSQLDB mysqldb/*.cpp mysqldb/*.h)
file(GLOB_RECURSE SRC_COMMON common/*.cpp common/*.h)

include_directories(httpserver mysqldb third_party common)

add_executable(${PROJECT_NAME} main.cpp ${SRC_HTTPSERVER} ${SRC_MYSQLDB} ${SRC_COMMON})

if (Poco_FOUND)
    target_link_libraries(${PROJECT_NAME}
        PRIVATE
        Poco::Foundation
        Poco::Util
        Poco::Net
        Poco::Data
        Poco::DataMySQL)
endif()
